package com.weetop.cfw.mine.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.weetop.cfw.R
import com.weetop.cfw.bean.AudioVideoDetailBean

class CourseDetailAdapter(layoutId: Int, dataList: List<AudioVideoDetailBean.DataBean>) :
    BaseQuickAdapter<AudioVideoDetailBean.DataBean, BaseViewHolder>(layoutId, dataList) {

    override fun convert(helper: BaseViewHolder, item: AudioVideoDetailBean.DataBean?) {
        if (item != null) {
            val textCourseTotalTime = helper.getView<TextView>(R.id.textCourseTotalTime)
            if (helper.adapterPosition.toString().length >= 2) {
                helper.setText(
                    R.id.textLessonTitle,
                    helper.adapterPosition.toString() + "." + item.title
                )
            } else {
                helper.setText(
                    R.id.textLessonTitle,
                    "0" + helper.adapterPosition.toString() + "." + item.title
                )
            }
                .setVisible(R.id.textIsPlayingLabel, item.isPlaying)
                .setVisible(R.id.imageIsPlayingLogo, item.isPlaying)
                .setVisible(R.id.textPlayLabel, !item.isPlaying)
                .setVisible(R.id.imagePlayLogo, !item.isPlaying)
            if (item.isFinished) {
                textCourseTotalTime.text =item.vftime+"秒"+"| 已完成"
            } else {
                textCourseTotalTime.text =item.vftime+"秒"

            }
        }
    }

}